from dolfin import *
from numpy import sin, cos

'''Proper way to rotate objects!'''

mesh = UnitSquareMesh(50,50)
V = FunctionSpace(mesh,'CG',1)

t = 0
count = 0
b = 0.25
a = -0.1
xc = 0.5 
yc = 0.5

out = File('rot_test.pvd')

while t < 80:
    v = interpolate(Expression('fabs(b+cos(a*t)*x[0]+sin(a*t)*x[1]-b*cos(a*t)-b*sin(a*t)-xc)+\
                                fabs(b-sin(a*t)*x[0]+cos(a*t)*x[1]-b*cos(a*t)+b*sin(a*t)-yc)-0.25',xc=xc,yc=yc,a=a,b=b,t=t),V)

    out << v, count
    count += 1
    t += 0.1

